package org.jprobe;

import java.io.File;

/**
* a workspace which is the directory that contains collection of projects
*
* @author Hussain Al-Mutawa
* @version 1.0
*/
public abstract class AbstractWorkspace {
	/**
	 * gets the path of the base directory from which projects are listed
	 * @return the file system path of the workspace
	 */
	public abstract String getPath();
	/**
	 * sets the path of the workspace
	 * @param path the file system path of the workspace
	 */
	public abstract void setPath(String path);

	/**
	 * gets the projects listed in the workspace
	 * @return the list of projects in the workspace
	 */
	public abstract Object[] getProjects();

	/**
	 * test if a directory is project or not
	 *
	 * @param directory the directory to be tested
	 * @return <code>true</code> if the directory tested is a project container, <code>false</code> otherwise
	 */
	public boolean isProject(final File directory){

		final boolean project   = new File(directory.getAbsolutePath()+"/.project").exists();
		final boolean classpath = new File(directory.getAbsolutePath()+"/.classpath").exists();

		return project && classpath;
	}
}